package com.gujianjian.com.config;

import com.gujianjian.com.annotation.Loggable;
import org.aopalliance.aop.Advice;
import org.springframework.aop.Pointcut;
import org.springframework.aop.support.AbstractPointcutAdvisor;
import org.springframework.aop.support.annotation.AnnotationMatchingPointcut;

public class CustomAdvisor extends AbstractPointcutAdvisor {

    private final Pointcut pointcut;
    private final Advice advice;

    public CustomAdvisor(LoggingAdvice advice) {
        // 定义切入点（例如：拦截所有带有 @Loggable 注解的方法）
        this.pointcut = new AnnotationMatchingPointcut(null, Loggable.class);
        this.advice = advice;
    }

    @Override
    public Pointcut getPointcut() {
        return this.pointcut;
    }

    @Override
    public Advice getAdvice() {
        return this.advice;
    }
}